<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['admin'])) {
header('Location: login.php');
}

$id = $_GET['id'];

$dbhandle= new PDO('sqlite:./datos/galeria.sqlite');

$result= $dbhandle->query("SELECT * FROM Pinturas WHERE Id='".$id."'");
$row = $result->fetch();
//generales:
$nombre = $row['NombreP'];
$artista = $row['Artista'];
$anio = $row['Anio'];
$museo = $row['Museo'];
$catID = $row['CId'];

$result= $dbhandle->query("SELECT NombreC FROM Categorias WHERE Id='".$catID."'");
$row = $result->fetch();
//categoria
$categoria = $row[0];

$result= $dbhandle->query("SELECT NombreE FROM Etiquetas WHERE PId='".$id."'");
$row = $result->fetch();
//etiquetas
$etiquetas = $row[0];
foreach ($result as $row)
{
	$etiquetas .= ', '.$row[0]; 
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

		<title>Art Vision - Modificar</title>
		<link rel="stylesheet" type="text/css" href="css/menu.css" />
		<link rel="stylesheet" type="text/css" href="css/view.css" media="all">
		<script type="text/javascript" src="js/view.js"></script>
		<script type="text/javascript" src="js/admin.js"></script>
		<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.min.js"></script>
	</head>

	<body>

		<img id="top" src="img/top.png" alt="">
		<div id="form_container">
	
		<h1>
			Formulario
		</h1>
		
		<form action="modificar.php" class="appnitro" method="post" onSubmit="return validar(this)" enctype="multipart/form-data">
			<div class="form_description">
				<h2>Formulario de Modificaci&oacute;n</h2>
				<p>Modifique los datos deseados y haga click en Enviar</p>
			</div>
			<div id="error_message">
				<p id="error_message_title">
				Error
				</p>
				<p id="error_message_desc">

				</p>
			</div>
			<fieldset>
				    <legend>Datos:</legend>
					<ul>
					<li>
						<label class="description" for="nombre">Nombre</label>
						<div>
							<input id="nombre" name="nombre" class="element text" type="text" size="50" maxlength="255" value="<?php echo $nombre;?>"/> 
						</div> 
					</li>
					<li>
						<label class="description" for="artista">Artista</label>
						<div>
							<input id="artista" name="artista" class="element text" size="50" type="text" maxlength="255" value="<?php echo $artista;?>"/> 
						</div> 
					</li>
					<li>
						<label class="description" for="anio">A&ntilde;o</label>
						<div>
							<input id="anio" name="anio" class="element text" size="50" type="text" maxlength="5" value="<?php echo $anio;?>"/> 
						</div> 
					</li>
					<li>
						<label class="description" for="museo">Museo</label>
						<div>
							<input id="museo" name="museo" class="element text" size="50" type="text" maxlength="255" value="<?php echo $museo;?>"/> 
						</div> 
					</li>
					<li>
						<label class="description" for="categoria">Categor&iacute;a</label>
						<div>
							<input id="categoria" name="categoria" class="element text" size="50" type="text" maxlength="255" value="<?php echo $categoria;?>"/> 
						</div> 
					</li>
					<li>
						<label class="description" for="etiquetas">Etiquetas</label>
						<div>
							<input id="etiquetas" name="etiquetas" class="element text" size="50" type="text" maxlength="255" value="<?php echo $etiquetas;?>"/> 
						</div>
						<p class="guidelines">
						<small>Incluya al menos una etiqueta. Deben estar separadas por coma.</small>
						</p> 
					</li>
					</ul>
			</fieldset>
			<!-- <fieldset>
				    <legend>Imagen:</legend>
					<ul>
					<li>
						<span>
						<input id="radio_file" name="radio" class="element radio" type="radio" value="file" />
						<label class="choice2" for="radio_file">Desde archivo</label>
						<input id="radio_url" name="radio" class="element radio" type="radio" value="url" />
						<label class="choice2" for="radio_url">Url</label>
						</span>
					</li>
					
					<li id="li_file">
						<label class="description" for="file">Archivo</label>
						<div>
							<input id="file" name="file" class="element file" type="file" size="50" accept="image/*" maxlength="255" value=""/> 
						</div> 
					</li>
					
					<li id="li_url">
						<label class="description" for="url">URL</label>
						<div>
							<input id="url" name="img_url" class="element text" type="url" size="50" maxlength="500" value=""/> 
						</div> 
					</li>
					</ul>
			</fieldset> -->
			<ul>
				<li class="buttons">
					<input id="enviar" class="button_text" type="submit" name="submit" value="Enviar" />
				</li>
			</ul>
			<input type="hidden" name="id" value="<?php echo $id;?>" id="id" /> 
		</form>
		</div>
		<img id="bottom" src="img/bottom.png" alt="">
		
	</body>
</html>